package com.example.demo.leetcode.zuocheng.graph;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xujm
 * @version V2.4
 * @since 2.4.0 2021/7/10 14:20
 */
public class String_一个字符创的所有子序列 {

    /**
     * 1.index到最后一位结束
     * 2.每次选择当前字符是加入path 或者不加入
     * @param arr
     * @param index
     * @param res
     * @param path
     */
    public static void subSequence(char [] arr,int index, List<String> res,String path){

        if(index == arr.length){
            res.add(path);
            return;
        }

        String no = path;
        subSequence(arr,index + 1,res ,no);
        String yes = path + String.valueOf(arr[index]);
        subSequence(arr,index + 1,res ,yes);
    }

    public static void main(String[] args) {

        String temp = "abcd";
        List<String> list = new ArrayList<>();
        subSequence(temp.toCharArray(),0,list,"");
        for(String a : list){
            System.out.println(a);
        }

    }




}
